package org.example.springmvc_demo7.model;

import lombok.Data;
import org.example.springmvc_demo7.enums.ResultStatus;

@Data
public class Result<T> {
    private ResultStatus code; //业务码 200-成功 -1-失败 -2-未登录
    private String errMsg;
    private T data;

    public static <T> Result success(T data){
        Result result = new Result<>();
        result.setCode(ResultStatus.SUCCESS);
        result.setData(data);
        return result;
    }

    public static <T> Result Fail(String errMsg){
        Result result = new Result<>();
        result.setCode(ResultStatus.FAIl);
        result.setErrMsg(errMsg);
        return result;
    }

    public static Result noLogin(){
        Result result = new Result<>();
        result.setCode(ResultStatus.NOLOGIN);
        result.setErrMsg("用户未登录");
        return result;
    }

}
